package com.cloud.product;

import com.cloud.dto.CartDto;
import com.cloud.input.ProductInfoOutput;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * describe:
 *
 * @author zhanghaixuan
 * @date 2018/09/11
 **/
@FeignClient(name = "product",fallback = ProductClient.ProductClientFallback.class)
public interface ProductClient {

    @GetMapping("/test/msg")
    String getMsg();

    @PostMapping("/product/listForOrder")
    List<ProductInfoOutput> findProductByIds(List<String> productLists);

    @PostMapping("/product/decreaseStock")
    void decreaseStock(List<CartDto> cartDtos);

    @Component
    static class ProductClientFallback implements ProductClient{
		@Override
		public String getMsg() {
			return null;
		}

		@Override
		public List<ProductInfoOutput> findProductByIds(List<String> productLists) {
			return null;
		}

		@Override
		public void decreaseStock(List<CartDto> cartDtos) {

		}
	}
}
